﻿
//谈单老师总结
var fnSumUp = function () {
    getSelected();
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    for (var i = 0; i < list.length; i++) {
        //this.getRecordSet()._records[0]._oData["BarItem"]
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
        }
    }
    ids = elist;
    if (ids.length > 1) {
        alert('只能选择一个客户进行总结');
    }
    if (ids.length > 0) {
        var id = ids[0];
       // parent.addTabs('谈单老师总结','MeetingArrange/ResourceManage.aspx?id='+ id + '&r=' + Math.random());

        window.parent.$("#tabs").tabs('close', '谈单老师总结');
        var pagetitle = "谈单老师总结";
        parent.addTabs(pagetitle, 'CRM/MeetingArrange/ResourceManage.aspx?id=' + id + '&r=' + Math.random() + '&title=' + encodeURI(pagetitle));
        parent.NeedRefreshPage = this;

       //document.getElementById("EditUIWindow").src = "MeetingArrange/ResourceManage.aspx?id=" + id + "&r=" + Math.random();
       // SetDWH(750, 450, YAHOO.example.container.dialog1);
        //YAHOO.example.container.dialog1.show();
    }
    else {
        alert('你没有选中任何项');
    }
}

//资源分配
var fnResourDeassign = function () {
    getSelected();
    if (ids.length > 1) {
        alert('只能选择一个客户进行资源分配');
    }
    if (ids.length > 0) {
        var id = ids[0];
        // parent.addTabs('谈单老师总结','MeetingArrange/ResourceManage.aspx?id='+ id + '&r=' + Math.random());

        window.parent.$("#tabs").tabs('close', '资源分配');
        var pagetitle = "资源分配";
        parent.addTabs(pagetitle, 'CRM/MeetingArrange/ResourceAssign.aspx?id=' + id + '&r=' + Math.random() + '&title=' + encodeURI(pagetitle));
        parent.NeedRefreshPage = this;

        //document.getElementById("EditUIWindow").src = "MeetingArrange/ResourceManage.aspx?id=" + id + "&r=" + Math.random();
        // SetDWH(750, 450, YAHOO.example.container.dialog1);
        //YAHOO.example.container.dialog1.show();
    }
    else {
        alert('你没有选中任何项');
    }
}

var getSelected = function () {
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    for (var i = 0; i < list.length; i++) {
        //this.getRecordSet()._records[0]._oData["BarItem"]
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
        }
    }
    ids = elist;

}
var fnFormatCustomerCode = function (elCell, oRecord, oColumn, sData) {
    if (sData == null || sData == "") {
        elCell.innerHTML = "";
    } else {
        elCell.innerHTML = "<a href='#'  onclick=\"showCustomer('" + oRecord._oData.CustomerId + "')\">" + oRecord._oData.CustomerCode + "</a>";
    }

}

var showCustomer = function (vid) {
    var pagetitle = "查看客户信息";
    parent.parent.addTabs(pagetitle, '../Crm/Customer/AddCustomerInfo.aspx?r=' + Math.random() + '&entity=CrmCustomerInfo&id=' + vid + '&title=' + encodeURI(pagetitle));
}

var fnSummary = function () {
    getSelected();
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    for (var i = 0; i < list.length; i++) {
        //this.getRecordSet()._records[0]._oData["BarItem"]
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
        }
    }
    ids = elist;
    if (ids.length > 1) {
        alert('只能选择一个客户进行总结');
    }
    if (ids.length > 0) {
        var id = ids[0];
        // parent.addTabs('谈单老师总结','MeetingArrange/ResourceManage.aspx?id='+ id + '&r=' + Math.random());


        window.parent.$("#tabs").tabs('close', '谈单老师总结');
        var pagetitle = "谈单老师总结";
        parent.addTabs(pagetitle, 'CRM/MeetingArrange/ResourceManage.aspx?id=' + id + '&r=' + Math.random() + '&title=' + encodeURI(pagetitle));
        parent.NeedRefreshPage = this;

        //document.getElementById("EditUIWindow").src = "MeetingArrange/ResourceManage.aspx?id=" + id + "&r=" + Math.random();
        // SetDWH(750, 450, YAHOO.example.container.dialog1);
        //YAHOO.example.container.dialog1.show();
    }
    else {
        alert('你没有选中任何项');
    }
}